package com.aktk.gameelements;

import java.util.ArrayList;
import com.aktk.gameelements.GamePlay.SegmentType;

public class Map {

	int rows;			// Width of game board
	int cols;			// Height of game board
	ArrayList<SegmentType> cells;	// An array of cells on the board: NULL, HIT, or MISS

	// Default constructor
	public Map( int numRows , int numCols ) {
		rows = numRows;
		cols = numCols;
		cells = new ArrayList<SegmentType>();
		for( int a = 0 ; a < (rows * cols) ; ++a )
		{
			cells.add(SegmentType.NULL);
		}
	}
	
	// Sets cell at specified coordinates to specified value
	public void setResult( int row , int col , SegmentType status )
	{
		cells.set(toCellNumber( row , col ) , status );
		/*
		if( result == true )
		{
			cells[ toCellNumber( x , y ) ] = cellCheck.HIT;
		}
		else
		{
			cells[ toCellNumber( x , y ) ] = cellCheck.MISS;
		}*/
	}
	
	public void setResult( int cellNum , SegmentType status )
	{
		cells.set( cellNum , status );
	}
	
	public SegmentType getResult( int cellNum )
	{
		return cells.get( cellNum );
	}
	
	public SegmentType getResult( int row , int col )
	{
		return cells.get( toCellNumber( row , col ) );
	}
	
	// Returns cell number for corresponding coordinates
	public int toCellNumber( int row , int col )
	{
		return ( row*cols + col );
	}
}
